import Layout from '../views/layout/Layout'

export const constantRoutes = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  { path: '/', redirect: '/dashboard', hidden: true }
]

export const adminRoutes = [
  {
    path: '/dashboard',
    component: Layout,
    hidden: false,
    children: [{
      path: '',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/admin',
    name: 'UserManagement',
    meta: { title: '用户管理' },
    children: [
      {
        path: 'admin',
        name: 'AdminList',
        component: () => import('@/views/acl/user/index'),
        meta: { 
          title: '管理员列表', 
          // icon: 'table',
          buttons: ['add', 'edit', 'delete'],
          role: 'admin'
        }
      },
      {
        path: 'list',
        name: 'UserList',
        component: () => import('@/views/acl/user/userList'),
        meta: { 
          title: '用户列表', 
          // icon: 'table',
          buttons: [ 'edit', 'delete'],
          role: 'admin'
        }
      }
    ]
  },
  {
    path: '/teacher',
    component: Layout,
    redirect: '/teacher/table',
    name: '讲师管理',
    meta: { title: '讲师管理' },
    children: [
      {
        path: 'list',
        name: '讲师列表',
        component: () => import('@/views/edu/teacher/list'),
        meta: { 
          title: '讲师列表', 
          // icon: 'table',
          buttons: ['add', 'edit', 'delete'],
          role: 'admin'
        }
      },
      {
        path: 'add',
        name: '添加讲师',
        component: () => import('@/views/edu/teacher/add'),
        meta: { 
          title: '添加讲师', 
          // icon: 'tree',
          buttons: ['save'],
          role: 'admin'
        }
      },
      {
        path: 'update/:id',
        name: '编辑讲师',
        component: () => import('@/views/edu/teacher/update'),
        meta: { 
          title: '编辑讲师', 
          noCache: true,
          buttons: ['save'],
          role: 'admin'
        },
        hidden: true
      }
    ]
  },
  {
    path: '/subject',
    component: Layout,
    redirect: '/subject/list',
    name: '课程分类管理',
    meta: { title: '课程分类管理' },
    children: [
      {
        path: 'list',
        name: '课程分类列表',
        component: () => import('@/views/edu/subject/list'),
        meta: { 
          title: '课程分类列表', 
          // icon: 'table',
          buttons: ['add', 'edit', 'delete']
        }
      }
    ]
  },
  {
    path: '/course',
    component: Layout,
    redirect: '/course/list',
    name: '课程管理',
    meta: { title: '课程管理' },
    children: [
      {
        path: 'list',
        name: '课程列表',
        component: () => import('@/views/edu/course/list'),
        meta: { 
          title: '课程列表', 
          // icon: 'table',
          buttons: ['add', 'edit', 'delete', 'publish']
        }
      },
      {
        path: 'info',
        name: '添加课程',
        component: () => import('@/views/edu/course/info'),
        meta: { 
          title: '添加课程', 
          // icon: 'tree',
          buttons: ['save']
        }
      },
      {
        path: 'updateInfo/:id',
        name: 'EduCourseInfoEdit',
        component: () => import('@/views/edu/course/updateInfo'),
        meta: { 
          title: '编辑课程基本信息', 
          noCache: true,
          buttons: ['save']
        },
        hidden: true,
        props: true
      },
      {
        path: 'updateChapter/:id',
        name: 'EduCourseChapterEdit',
        component: () => import('@/views/edu/course/updateChapter'),
        meta: { 
          title: '编辑课程章节信息', 
          noCache: true,
          buttons: ['save']
        },
        hidden: true,
        props: true
      },
      {
        path: 'publish/:id',
        name: 'EduCoursePublishEdit',
        component: () => import('@/views/edu/course/publish'),
        meta: { 
          title: '发布课程', 
          noCache: true,
          buttons: ['publish']
        },
        hidden: true,
        props: true
      }
    ]
  },
  {
    path: '/cms',
    component: Layout,
    redirect: '/cms/banner',
    name: '内容管理',
    meta: { title: '内容管理' },
    children: [
      {
        path: 'banner',
        name: 'Banner管理',
        component: () => import('@/views/edu/banner/BannerList'),
        meta: { 
          title: 'Banner管理', 
          // icon: 'table',
          buttons: ['add', 'edit', 'delete']
        }
      }
    ]
  },
  {
    path: '/orders',
    component: Layout,
    redirect: '/orders/list',
    name: '订单管理',
    meta: { title: '订单管理' },
    children: [
      {
        path: 'list',
        name: '订单列表',
        component: () => import('@/views/orders/list'),
        meta: { 
          title: '订单列表', 
          // icon: 'table',
          buttons: ['view', 'delete']
        }
      }
    ]
  },
  {
    path: '/sta',
    component: Layout,
    redirect: '/sta/create',
    name: '统计分析',
    meta: { title: '统计分析'},
    children: [
      {
        path: 'create',
        name: '生成数据',
        component: () => import('@/views/sta/create'),
        meta: { 
          title: '生成数据', 
          // icon: 'table',
          buttons: ['generate']
        }
      },
      {
        path: 'show',
        name: '图表显示',
        component: () => import('@/views/sta/show'),
        meta: { 
          title: '图表显示', 
          // icon: 'tree',
          buttons: ['export']
        }
      }
    ]
  },
  {
    path: '/note',
    component: Layout,
    redirect: '/note/list',
    name: '笔记管理',
    meta: { title: '笔记管理' },
    children: [
      {
        path: 'list',
        name: '笔记列表',
        component: () => import('@/views/note/list'),
        meta: { 
          title: '笔记列表', 
          // icon: 'table',
          buttons: ['view', 'delete']
        }
      }
    ]
  },
  {
    path: '/question',
    component: Layout,
    redirect: '/question/list',
    name: 'QuestionManagement',
    meta: { title: '问题管理' },
    children: [
      {
        path: 'list',
        name: 'QuestionList',
        component: () => import('@/views/qa/list'),
        meta: {
          title: '问题列表',
          buttons: ['view','delete']
        }
      }
    ]
  }
]

// 讲师路由
export const teacherRoutes = [
  {
    path: '/dashboard',
    component: Layout,
    children: [{
      path: '',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard', roles: ['admin', 'teacher'] }
    }]
  },
  {
    path: '/subject',
    component: Layout,
    redirect: '/subject/list',
    name: '课程分类管理',
    meta: { title: '课程分类管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '课程分类列表',
        component: () => import('@/views/edu/subject/list'),
        meta: { 
          title: '课程分类列表', 
          icon: 'table',
          buttons: ['view']
        }
      }
    ]
  },
  {
    path: '/course',
    component: Layout,
    redirect: '/course/list',
    name: '课程管理',
    meta: { title: '课程管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '课程列表',
        component: () => import('@/views/edu/course/list'),
        meta: { 
          title: '课程列表', 
          icon: 'table',
          buttons: ['add', 'edit', 'delete', 'publish']
        }
      },
      {
        path: 'info',
        name: '添加课程',
        component: () => import('@/views/edu/course/info'),
        meta: { 
          title: '添加课程', 
          icon: 'tree',
          buttons: ['save']
        }
      },
      {
        path: 'updateInfo/:id',
        name: 'EduCourseInfoEdit',
        component: () => import('@/views/edu/course/updateInfo'),
        meta: { 
          title: '编辑课程基本信息', 
          noCache: true,
          buttons: ['save']
        },
        hidden: true,
        props: true
      },
      {
        path: 'updateChapter/:id',
        name: 'EduCourseChapterEdit',
        component: () => import('@/views/edu/course/updateChapter'),
        meta: { 
          title: '编辑课程章节信息', 
          noCache: true,
          buttons: ['save']
        },
        hidden: true,
        props: true
      },
      {
        path: 'publish/:id',
        name: 'EduCoursePublishEdit',
        component: () => import('@/views/edu/course/publish'),
        meta: { 
          title: '发布课程', 
          noCache: true,
          buttons: ['publish']
        },
        hidden: true,
        props: true
      }
    ]
  },
  {
    path: '/note',
    component: Layout,
    redirect: '/note/list',
    name: '笔记管理',
    meta: { title: '笔记管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '笔记列表',
        component: () => import('@/views/note/list'),
        meta: { 
          title: '笔记列表', 
          icon: 'table',
          buttons: ['view', 'delete']
        }
      }
    ]
  }
]

export default {
  constantRoutes,
  adminRoutes,
  teacherRoutes
}
